<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>管理系统</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  {:widget_st('layui','css')}
  {:widget_st('admin','css')}
</head>
{:do_action('admin_head')}
<body>

  <div class="layui-fluid">
    <div class="layui-card">
      <form class="info_tj">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
          <div class="layui-form-item">
            <input type="hidden" name="mid" id="" value="{$mid}">
            <div class="layui-inline">
              <label class="layui-form-label">名称</label>
              <div class="layui-input-block">
                <input type="text" name="name" placeholder="请输入" autocomplete="off" class="layui-input">
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">键</label>
              <div class="layui-input-block">
                  <select name="key" lay-filter="key">
                    <?php foreach($key_list as $k=>$vo){ if(!isset($vo['Field'])){ $vo['Field'] = $vo['field']; }  if($vo['Field']!='id'){ ?>
                      <option value="{$vo['Field']}" >{$vo['Field']}</option>
                    <?php }}?>
                  </select>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">值</label>
              <div class="layui-input-inline">
                <input type="text" name="value" placeholder="请输入" autocomplete="off" class="layui-input">
              </div>
            </div>
             <div class="layui-inline">
              <label class="layui-form-label">类型</label>
              <div class="layui-input-block">
                <!-- <input type="text" name="sort" placeholder="请输入" autocomplete="off" class="layui-input"> -->
                <select name="type" lay-filter="type">
                  <?php foreach(formProActionArr() as $k=>$vo){  ?>
                    <option value="{$vo['id']}" >{$vo['name']}</option>
                  <?php }?>
                </select>
              </div>
            </div>
            <div class="layui-inline">
                <a class="layui-btn layui-btn-sm tj_btn"  >新增</a>
            </div>
          </div>
        </div>
      </form>
      <div class="layui-card-body">
        <table class="layui-table">
            <colgroup>
              <col width="30">
              <col width="60">
              <col width="60">
              <col width="60">
              <col width="50">
              <col width="50">
              <col width="60">
              <col width="50">
              <col width="50">
              <col width="50">
              <col width="50">
              <col width="50">
              <col>
            </colgroup>
            <thead>
              <tr>
                <th>ID</th>
                <th>名称</th>
                <th>键</th>
                <th>默认值</th>          
                <th>位置(默认左)</th>
                <th>类型</th>
                <th>只读</th>
                <th>隐藏</th>
                <th>多个</th>
                <th>排序</th>
                <th>状态</th>
                <th>操作</th>
              </tr> 
            </thead>
            <tbody>
              <?php foreach($list as $k=>$vo){ ?>
                <tr>
                  <td>{$vo['id']}</td>
                  <td>
                    <input type="text" autocomplete="off" class="layui-input edit_sort" item-dbname="category_model_parm" item_f="name"  value="{$vo['name']}" item-id="{$vo['id']}"  >
                  </td>
                  <td><?php echo \Wmc1125\TpFast\ZfTool::str_in_two_array($vo['key'],$all_list)?$vo['key']:$vo['key'].'不存在,请关闭'; ?></td>
                  <td>
                    <input type="text" autocomplete="off" class="layui-input edit_sort" item-dbname="category_model_parm" item_f="value"  value="{$vo['value']}" item-id="{$vo['id']}"  >                  
                  </td>
                  <td>{$vo['position']==1?'左':'右'}</td>
                  <td>{$vo['type']}</td>
                  <td>{$vo['readonly']==1?'是':'否'}</td>
                  <td>{$vo['hidden']==1?'是':'否'}</td>
                  <td>{$vo['is_multi']==1?'是':'否'}</td>
                  <td>
                    <input type="text" autocomplete="off" class="layui-input edit_sort" item-dbname="category_model_parm" item_f="sort"  value="{$vo['sort']}" item-id="{$vo['id']}"  >                                      
                  </td>
                  <td> 
                    <div class=" layui-form" lay-filter="component-form-element">        
                       <input type="checkbox" name="status" <?php echo $vo['status']==1?'checked':''; ?> lay-skin="switch" lay-text="开启|关闭" lay-filter="status_change" item="{$vo['id']}">
                    </div>
                  </td>
                  <td>  
                      <button class="layui-btn layui-btn-sm" onclick='zfAdminShow("编辑","{:url('admin/category/category_model_parm_edit',['id' => $vo['id']] )}",800)'>编辑</button> 
                      <a class="layui-btn btn_del layui-btn-danger layui-btn-sm" rel="{$vo['id']}" href="#">删除</a> 
                    </td>
                </tr>
              <?php } ?>         
            </tbody>
          </table>
      </div>
    </div>
  </div>
  {:widget_st('jq','js')}
  {:widget_st('layui','js')}  
  {:widget_st('common','js')} 

  <script>
 layui.use([ 'table','element'], function(){
    var $ = layui.$
    ,form = layui.form
    ,element = layui.element
    ,table = layui.table;

    form.on('switch(status_change)', function(data){
      var id = $(this).attr("item")
      var dbname = 'category_model_parm'
      var status = this.checked ? '1' : '0'
      console.log(id)
      $.get("{:url('admin/common/is_switch')}",{id:id,dbname:dbname,status:status},function(res){
          if(res.result==1){
            layer.msg(res.msg, {icon: 1});
          }else{
            layer.msg(res.msg, {icon: 2});
          }
        },"json");
    });
    $(".tj_btn").on("click",function(){
        var index = layer.load(2);
		var data = $(".info_tj input,.info_tj select,.info_tj textarea,.info_tj option,.info_tj radio").serialize();      
      	$.ajax({
          type:'post',
          url:"{:url('admin/category/category_model_parm_add')}",
          data:data,
          dataType:'json',
          success:function(res){
            if(res.result==1){
              layer.msg(res.msg, {icon: 1});
              layer.close()
              setTimeout(function() {
					       window.location.reload();
              }, 2000);
            }else{
              layer.msg(res.msg, {icon: 2});
              layer.close(index)
            }   
          }
      	})
    })
    // 删除
    $(".btn_del").on("click",function(){
      var id = $(this).attr("rel");
      layer.confirm('确认删除？', {
        btn: ['删除','取消']
      }, function(){
        
        $.get("{:url('admin/common/del_post')}",{id:id,db:'category_model_parm'},function(res){
          if(res.result==1){
            layer.msg("删除成功", {icon: 1});
            setTimeout(function() {
              location.reload(true);
            }, 1000);
          }else{
            layer.msg(res.msg, {icon: 2});
          }
        },"json");

      }, function(){
          //取消的操作
      });
    });

   


    
    
 
   
  });
  </script>
</body>
</html>
{:do_action('admin_js')}
